<template>
  <div>
    <!-- <div class="top_hytitle">
              <div class="letf_line"></div>
              <div class="center_text">欢迎回来</div>
              <div class="right_line"></div>
            </div> -->
    <div class="">
      <p style="margin: 15px 0; color: #9998a9">
        {{ formatTimestamp(topList.createTime) }}
      </p>
      <div class="top-box" :class="isShadow?'boxShadow':''">
          <img src="../../assets/iconIndex/zxrb_logo.png" class="zxrb_logo" alt="">
        <!-- <p>{{ topList.title }}</p> -->
        <div class="top-box-list" style="background: linear-gradient(180deg, rgba(8,131,241,0.028) 0%, rgba(8,131,241,0.012) 100%);border: 1px solid rgba(8,131,241,0.08);padding-bottom: 17px;">
          <div
            v-for="(topItemCard, topItemIndex) in topList.card"
            class="top-box-list-item"
            :key="topItemIndex"
            :style="{
              marginBottom:
                topItemIndex === topList.card.length - 1 ? '0px' : '30px',
            }"
            @click="gotozxrbdetails(topItemCard)"
          >
            <p>{{ topItemCard.name }}</p>
            <p>{{ topItemCard.sub }}</p>
          </div>
        </div>
        <div class="top-box-btn" @click="djrbseechance">
          点击日报查看更多机会信息
        </div>
        <p class="askMe">你可以尝试这样问我</p>
        <div
          @click="sendMessageBy(topItemLink)"
          v-for="(topItemLink, topItemLinkIndex) in topList.link"
          class="top-box-list-item-link"
          :key="topItemLinkIndex"
        >
          {{ topItemLink }}
        </div>
      </div>
    </div>
  </div>
</template>
    
    <script>
import {} from "@/utils/common";
import { Toast } from "vant";
import commonFunc from "@/utils/ysjh";
export default {
  data() {
    return {};
  },
  props: {
    topList: {
      type: Object,
      default: () => {},
    },isShadow: {
    type: Boolean,
    default: false,
  },
  },
  watch: {},
  mounted() {
    console.log(this.topList, "topList");
  },
  created() {},
  methods: {
    //去排雷查看详情
    gotosldetails(item) {
      console.log(item.name, "item,item");
      const leftBracketIndex = item.name.indexOf("（");
      const rightBracketIndex = item.name.indexOf("）");
      if (leftBracketIndex !== -1 && rightBracketIndex !== -1) {
        const stockName = item.name.substring(0, leftBracketIndex);
        const stockCode = item.name.substring(
          leftBracketIndex + 1,
          rightBracketIndex
        );
        console.log(stockName, stockCode);
        stockCode.toString();
        let code = "";
        if (stockCode.substr(0, 2) == "68") {
          code = "0107" + stockCode;
        } else if (stockCode.substr(0, 1) == "6") {
          code = "0101" + stockCode;
        } else if (
          stockCode.substr(0, 1) == "0" ||
          stockCode.substr(0, 1) == "3"
        ) {
          code = "0001" + stockCode;
        } else if (
          stockCode.substr(0, 1) == "4" ||
          stockCode.substr(0, 1) == "8"
        ) {
          code = "0401" + stockCode;
        } else if (stockCode.substr(0, 1) == "5") {
          code = "0103" + stockCode;
        } else if (stockCode.substr(0, 1) == "1") {
          code = "0003" + stockCode;
        }
        console.log(code, "codecodecode");
        console.log(stockName, "stockName");

        const JumpUrl =
          "http://guoyuan4.dengtacj.cn:55561/MineScanner/index.html#/pages/mineDimension/mineDimension?stockCode=" +
          code +
          "&stockName=" +
          stockName;
        commonFunc.openService("", "4", "KDS_WebPageWithHead", {
          webUrl: JumpUrl,
          loginType: "1",
        });
      }
    },
    //去日报查看详情
    gotozxrbdetails(item) {
      console.log(item, "itme");
      let openSource = item.url.openSource;
      let openType = item.url.openType;
      let functionCode = item.url.functionCode;
      let param = item.url.param;
      commonFunc.openService(openSource, openType, functionCode, param);
      // console.log(item.name, "item,item");
      // const leftBracketIndex = item.name.indexOf("（");
      // const rightBracketIndex = item.name.indexOf("）");
      // if (leftBracketIndex !== -1 && rightBracketIndex !== -1) {
      //   const stockName = item.name.substring(0, leftBracketIndex);
      //   const stockCode = item.name.substring(
      //     leftBracketIndex + 1,
      //     rightBracketIndex
      //   );
      //   commonFunc.openService("", "3", "FN_Native_HangQing_StockDetail", {
      //     dzhStockCode: stockCode,
      //     dzhStockType: "1",
      //     stockName: stockName,
      //   });
      // }
    },
    //点击日报查看更多机会
    djrbseechance() {
      let openSource = this.topList.url.openSource;
      let openType = this.topList.url.openType;
      let functionCode = this.topList.url.functionCode;
      let param = this.topList.url.param;
      commonFunc.openService(openSource, openType, functionCode, param);
    },
    //点击查看更多自选风险信息
    djseegdfxnews() {
      const JumpUrl = "https://guoyuan4.mdengta.com/MineScanner/index.html";
      console.log(JumpUrl, "JumpUrlJumpUrl");
      commonFunc.openService("", "4", "KDS_WebPageWithHead", {
        webUrl: JumpUrl,
        loginType: "1",
      });
    },
    sendMessageBy(e) {
      this.$parent.showCollect = false;
      this.$parent.someMethod(e);
    },
    formatTimestamp(ms) {
      if (!ms) {
        return "";
      }
      const time = Number(ms);
      if (!time || isNaN(time)) return "-";
      const d = new Date(time);
      const Y = d.getFullYear();
      const M = String(d.getMonth() + 1).padStart(2, "0");
      const D = String(d.getDate()).padStart(2, "0");
      const h = String(d.getHours()).padStart(2, "0");
      const m = String(d.getMinutes()).padStart(2, "0");
      const s = String(d.getSeconds()).padStart(2, "0");
      return `${Y}-${M}-${D} ${h}:${m}:${s}`;
    },
  },
};
</script>
    
   <style lang="less" scoped>
   .zxrb_logo{
     width: 208px;
     height: 23px;
   }
</style>
    